#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>

using namespace std;
using LL = long long;

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T;
    cin >> T;
    while(T--){
        int n, m;
        cin >> n >> m;
        if(n == 1 && m == 1){
            cout << 0 << '\n';
            continue;
        }
        int res = m + n - 2 + min(n - 1, m - 1) + 1;
        cout << res << '\n';
    }


    return 0;
}